window.onload=function () {
    var order_url = '/user/get-order';
    var order_config = {
        elem: '#order'
        ,url:order_url
        ,cols: [[
            {field:'id', width:86, title: '订单编号'},
            {field:'order_status', width:86, title: '订单状态',templet:function(item){
                    return getStatus(parseInt(item.order_status));
                }},
            {field:'shop_name', width:80, title: '店铺'},
            {field:'active_name', width:86, title: '商品名称'},
            {field:'order_money', width:86, title: '订单金额'},
            {field:'addressee_name', width:80, title: '收货人'},
            {field:'addressee_phone', width:120, title: '联系电话'},
            {field:'address', minWidth:80, title: '收货地址'},
            {field:'created_time', width:86, title: '下单时间',templet:function (item) {
                    var time = parseInt(item.created_time) ? timestampToTime(parseInt(item.created_time)) : '';

                    return time;
                }},
            {field:'complete_time', width:86, title: '完成时间',templet:function (item) {
                    var time = parseInt(item.complete_time) ? timestampToTime(parseInt(item.complete_time)) : '';
                    return time;
                }},
        ]]
        ,page: true
    };
    var address_url = '/user/get-address';
    var address_config = {
        elem: '#address'
        ,url:address_url
        ,cols: [[
            {field:'status',type:'radio', width:80, title: '默认',width: 100, align:'center', templet:function(d){
                    var checked = d.status == 1 ? 'checked' : '';
                    return '<input type="checkbox"  data-id="'+d.id +'" '+checked+' disabled lay-skin="switch" lay-text="是|否" '+d.newsTop+'>'
                }},
            {field:'name', width:100, title: '收货人'},
            {field:'mobile', width:120, title: '联系方式'},
            {field:'province', width:115, title: '收货地址(省)'},
            {field:'city', width:115, title: '收货地址(市)'},
            {field:'area', width:115, title: '收货地址(区)'},
            {field:'district', minWidth:80, title: '收货地址(详细地址)'}
        ]]
    };
    layui.use(['form','layer','jquery','table'], function(){
        var table = layui.table,
            form = layui.form,
            layer = layui.layer;
            $ = layui.jquery;
        var user_id = $("#user_id").val();
        var order_url = '/user/get-order?id='+user_id;
        order_config.url = order_url;
        table.render(order_config);
        var address_url = '/user/get-address?id='+user_id;
        address_config.url = address_url;
        table.render(address_config);

    });
};